import {mockApplicants} from "../mock/data.ts";
import type {Applicant, JobPost, PaginationData} from "../vite-env.d";
import {HttpService} from "../assets/Http.ts";

export default class RecruiterService {
    async getApplicantPages(recruiterId: number, jobPostId: number, page: number, rowsPerPage: number): Promise<PaginationData<Applicant>> {
        return (await HttpService.get("/recruiter/getApplicantList", {
            recruiter_id: recruiterId,
            job_post_id: jobPostId,
            page: page,
            rows_per_page: rowsPerPage
        })).data;
    }
    async getJobPages(recruiterId: number, page: number, rowsPerPage: number): Promise<PaginationData<JobPost>> {
        return (await HttpService.get("/recruiter/getJobPages", {
            recruiter_id: recruiterId,
            page: page,
            rows_per_page: rowsPerPage
        })).data
    }
    async saveJobPost(recruiterId: number, jobPost: JobPost) {
        if (!recruiterId && !(jobPost && jobPost.title && jobPost.company && jobPost.salary && jobPost.location)) {
            throw new Error("缺少必要的参数")
        }
        console.log("recruiterId, jobPost", recruiterId, jobPost)
        return HttpService.post("/recruiter/saveJobPost", {
            ...jobPost, recruiter_id: recruiterId
        }, {headers: { 'Content-Type': 'application/json' }})
    }
}